package com.cmcc.driver.data.service

import com.cmcc.driver.data.entity.Order
import com.cmcc.driver.data.entity.OrderDetail
import com.cmcc.driver.data.entity.OrderStatus
import com.cmcc.driver.data.entity.OrderTemp
import com.cmcc.driver.data.entity.request.CarUpdateRequest
import com.cmcc.driver.data.entity.request.DeviceToken
import com.cmcc.driver.data.entity.request.MyLatLng
import com.cmcc.driver.data.entity.request.OrderReceiving
import com.cmcc.driver.data.entity.response.CarCategory
import com.cmcc.driver.data.entity.response.CarInfo
import com.cmcc.driver.data.entity.response.Feedback
import com.cmcc.driver.data.entity.response.OrderRecord
import com.cmcc.shared.model.AppResponse
import com.cmcc.shared.model.DriverCache
import com.cmcc.shared.model.DriverInfo
import com.cmcc.shared.model.MsgBean
import kotlinx.coroutines.Deferred
import retrofit2.Response
import retrofit2.http.*

/**
 * Author: jiangxin
 * Date: 2019/11/8
 * Description:
 */
interface ApiService {

//    /**
//     * 请求订单记录
//     */
//    @GET("consumer/order/list")
//    fun getOrderRecords(
//        @Query("current") page: Int,
//        @Query("size") pageSize: Int,
//        @Query("role") role: Int,
//        @Query("status") status: Int?
//    ): Deferred<Response<AppResponse<OrderRecord>>>

    /**
     * 请求订单记录
     */
    @GET("consumer/order/list")
    fun getOrderRecords(
        @Query("current") page: Int,
        @Query("size") pageSize: Int,
        @Query("role") role: Int,
        @Query("status") status: Int?,
        @Query("statusOperator") statusOperator:String
    ): Deferred<Response<AppResponse<OrderRecord>>>

    /**
     * 获取出单列表
     */
    @GET("consumer/order/list")
    fun getOrderListInProgress(
        @Query("current") page: Int,
        @Query("size") pageSize: Int,
        @Query("role") role: Int,
        @Query("status") status: Int,
        @Query("statusOperator") statusOperator:String
    ): Deferred<Response<AppResponse<OrderRecord>>>

    /**
     * 获取附近的订单
     */
    @GET("consumer/order/nearby")
    fun nearbyOrder(
        @Query("latitude") latitude: String,
        @Query("longitude") longitude: String,
        @Query("kilometers") kilometers: Int
    ): Deferred<Response<AppResponse<List<Order>>>>


    /**
     * 查询正在进行的订单
     */
    @GET("consumer/order/in/process")
    fun queryOrderInProgress(@Query("role") role: Int): Deferred<Response<AppResponse<OrderDetail>>>

    /**
     * 接单
     * @param
     */
    @POST("consumer/order/receiving")
    fun receivingOrder(@Body orderReceiving: OrderReceiving): Deferred<Response<AppResponse<String>>>

    @PUT("consumer/order/action")
    fun actionOrder(@Body orderReceiving: OrderReceiving): Deferred<Response<AppResponse<String>>>

    /**
     * 下一步操作
     */
    @PUT("consumer/order/process/next")
    fun nextOrder(@Body orderStatus: OrderStatus): Deferred<Response<AppResponse<Int>>>

    /**
     * 获取订单详情
     */
    @GET("consumer/order/detail")
    fun orderDetail(@Query("orderId") id: String): Deferred<Response<AppResponse<OrderDetail>>>

    /**
     * 获取订单详情
     */
    @GET("consumer/driver/cancel/order/number")
    fun orderNumber(): Deferred<Response<AppResponse<Double>>>

    /**
     * 获取我的车辆信息
     */
    @GET("consumer/driver/car/list")
    fun getCarInfo(): Deferred<Response<AppResponse<List<CarInfo>>>>

    @GET("consumer/dictionary/vehicle/type/list")
    fun getCarCategory(): Deferred<Response<AppResponse<List<CarCategory>>>>


    /**
     * 更新司机位置，每隔一段时间需要调用一次
     * @param myLatLng 司机的当前坐标
     */
    @PUT("consumer/driver/current/coordinates")
    fun updateLocation(@Body myLatLng: MyLatLng): Deferred<Response<AppResponse<String>>>

    /**
     * 取消已接订单
     */
    @DELETE("consumer/order/cancel/call")
    fun canelOrder(): Deferred<Response<AppResponse<String>>>

    /**
     * 获取司机缓存，缓存中包含了一些司机的信息
     * @param id driver id
     *
     */
    @GET("consumer/driver/cache")
    fun getDriverCache(@Query("id") id: String): Deferred<Response<AppResponse<DriverCache>>>

    @GET("/consumer/driver/current/info")
    fun getDriverInfo(): Deferred<Response<AppResponse<DriverInfo>>>

    /**
     * 更新车辆信息
     */
    @PUT("consumer/driver/car")
    fun updateCarInfo(@Body carInfo : CarUpdateRequest) :Deferred<Response<AppResponse<String>>>


    /**
     * 意见反馈
     */
    @POST("consumer/complaint-record")
    fun feedback(@Body feedback: Feedback): Deferred<Response<AppResponse<String>>>

    @POST("consumer/msg/sync/device-token")
    fun syncDeviceToken(@Body deviceToken: DeviceToken): Deferred<Response<AppResponse<String>>>

    /**
     * 获取订单模板
     * @param id order template id
     */
    @GET("consumer/order/temp")
    fun getOrderTemplate(@Query("id") id: String): Deferred<Response<AppResponse<OrderTemp>>>

    /**
     * 消息列表
     */
    @GET("/consumer/system/message/list")
    fun list(@Query("pageNum") pageNum: Int,@Query("pageSize") pageSize: Int): Deferred<Response<AppResponse<MsgBean>>>



    /**
     * 拒单
     */
    @POST("consumer/order/refusal/{id}")
    fun refusalOrder(@Path("id") id: String): Deferred<Response<AppResponse<Boolean>>>



    /**
     * 取消订单
     */
    @POST("/consumer/order/driver/cancel/call")
    fun cancel(@retrofit2.http.QueryMap map: Map<String, String> ) :Deferred<Response<AppResponse<Boolean>>>

}